#!perl

use 5.010;
use strict;
use warnings;

use Test::More tests => 3;

use JasPerl::Util::Date;
use JasPerl::Util::TimeZone;

use Time::Piece;

my $tz = JasPerl::Util::TimeZone->get_default();
print "local timezone is $tz (", $tz->get_id(), ")\n";

my $utc = JasPerl::Util::TimeZone->get_time_zone('UTC');
my $now = JasPerl::Util::Date->new();

# $tz->get_offset
print "offset now: ", $tz->get_offset($now), "\n";
print "offset epoch: ", $tz->get_offset(0), "\n";

is $utc->get_offset($now), 0, "  utc offset";
is $utc->get_offset(0), 0, "  utc offset";

# $tz->get_local_offset
print "local offset now: ", $tz->get_local_offset($now->as_localtime()), "\n";
print "local offset epoch: ", $tz->get_local_offset(0, 0, 0, 1, 0, 0), "\n";

is $utc->get_local_offset($now->as_localtime()), 0, "  utc offset";
is $utc->get_local_offset(0, 0, 0, 1, 0, 0), 0, "  utc offset";

# $tz->clone
my $clone = $tz->clone();
is $tz->get_id(), $clone->get_id(), "  clone";
$clone->set_id('foobar');
isnt $tz->get_id(), $clone->get_id(), "  clone";
is $tz->get_offset($now), $clone->get_offset($now), "  clone";

